import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ItemData } from "../../resource/info/ItemData";
import { ItemsUtil } from "../shortcuts/item/ItemsUtil";
import { Cache } from "../../cache/Cache";
import { Language } from "../../../../extend/language/Language";
import { EffectManager } from "../../manager/EffectManager";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { BaseItem } from "../common/BaseItem";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class FGRewardCellRenderer
    
    export  class FGRewardCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=false;
            var loc2=0;
            super.data = arg1;
            this._itemData = arg1 as ItemData;
            this._baseItem.itemData = this._itemData;
            if (this._itemData) 
            {
                this._nameTxt.htmlText = ItemsUtil.getItemName(this._itemData);
                loc1 = Cache.instance.footballGuess.isHasRewards(this._itemData.itemCode);
                if (loc1) 
                {
                    this._getBtn.enabled = true;
                    this._getBtn.label = Language.getString(53008);
                    loc2 = Cache.instance.footballGuess.rewards[this._itemData.itemCode];
                    if (loc2 > 0) 
                    {
                        this._baseItem.setAmountLabel(loc2.toString());
                    }
                }
                else 
                {
                    this._getBtn.enabled = false;
                    if (Cache.instance.footballGuess.isGetedReward(this._itemData.itemCode)) 
                    {
                        this._getBtn.label = Language.getString(57165);
                        loc2 = Cache.instance.footballGuess.hadGetRewards[this._itemData.itemCode];
                        if (loc2 > 0) 
                        {
                            this._baseItem.setAmountLabel(loc2.toString());
                        }
                    }
                }
                if (this._getBtn.enabled) 
                {
                    EffectManager.glowFilterReg(this._getBtn, FGRewardCellRenderer.filterArr, 0.8, 10, 5);
                }
                else 
                {
                    EffectManager.glowFilterUnReg(this._getBtn);
                }
                this._getBtn.drawNow();
            }
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(65, 0, 117, 25, this, ImagesConst.FightingStrgBg);
            this._nameTxt = ObjCreate.createTextField("", 75, 2.5, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, null, true));
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            ObjCreate.createBg(0, 0, 68, 68, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.setSize(62, 62);
            this._baseItem.move(3, 2);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            this._baseItem.setAmountLabelPos(-3, 48);
            this.addChild(this._baseItem);
            this._getBtn = ObjCreate.createGButton(Language.getString(53008), 95, 42, 50, 24, this, "ButtonRed");
            this._getBtn.drawNow();
            this._getBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onGetBtnClickHandler);
            this._lineBox = new Object /* flash.display.Sprite */();
            this._lineBox.graphics.lineStyle(3, 15788607, 1);
            this._lineBox.graphics.drawRect(0, 0, this.width, 72);
            this._lineBox.graphics.endFill();
            this._lineBox.mouseChildren = false;
            this._lineBox.mouseEnabled = false;
            return;
        }

        /* internal  */onGetBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            if (this._itemData) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.FootballGuessGetReward, {"itemCode": this._itemData.itemCode, "callBackFun": this.getSuccess}));
            }
            return;
        }

        /* internal  */getSuccess(): void
        {
            this._getBtn.label = Language.getString(57165);
            this._getBtn.enabled = false;
            this._getBtn.drawNow();
            EffectManager.glowFilterUnReg(this._getBtn);
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            super.selected = arg1;
            if (arg1) 
            {
                if (!this.contains(this._lineBox)) 
                {
                    this.addChild(this._lineBox);
                }
            }
            else if (this.contains(this._lineBox)) 
            {
                this.removeChild(this._lineBox);
            }
            return;
        }

        /* internal */ static /* const */filterArr: Array<any>=[new Object /* flash.filters.GlowFilter */(16777062, 1, 6, 6, 4)];

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_getBtn: GButton;

        /* internal */ /* var */_lineBox: Object /* flash.display.Sprite */;

        /* internal */ /* var */_itemData: ItemData;

        /* internal */ /* var */_guessSuccessNum: int;

        /* internal */ /* var */_fourGuessSuccessNum: int;

        /* internal */ /* var */_isGuessChampion: Boolean;
    }
